package app.qrcode.browser.hearttoheart.activities

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import app.qrcode.browser.hearttoheart.MyApplication.Companion.context
import app.qrcode.browser.hearttoheart.R
import app.qrcode.browser.hearttoheart.adapters.Images
import app.qrcode.browser.hearttoheart.adapters.ImagesAdapter
import app.qrcode.browser.hearttoheart.databinding.ActivityMyPrepareBinding
import com.youth.banner.indicator.CircleIndicator

class MyPrepareActivity : AppCompatActivity() {

    private var imageList: MutableList<Images> = mutableListOf()

    private lateinit var binding: ActivityMyPrepareBinding


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivityMyPrepareBinding.inflate(layoutInflater)
        setContentView(binding.root)
        initBanner(imageList)
        useBanner()
    }

     private fun useBanner() {
        binding.banner.addBannerLifecycleObserver(this)//添加生命周期观察者
            .setAdapter(ImagesAdapter(imageList)).indicator = CircleIndicator(context)
    }

    private fun initBanner(imageList: MutableList<Images>) {
        imageList.add(Images(R.mipmap.one))
        imageList.add(Images(R.mipmap.two))
        imageList.add(Images(R.mipmap.three))
    }
}